package com.jiepos.mpos.biz.channel.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.jiepos.mpos.biz.channel.service.InfChnGrpService;
import com.jiepos.mpos.common.entity.App_Inf_Chn_GrpEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;

/**
 * 
 * 
 * <p>标题: —— 通道分组表控制器</p>
 * <p>模块: 通用平台</p>
 * <p>版权: Copyright (c) 2017 江苏杰博实信息技术有限公司
 * @ProjectName:  [mpos] 
 * @Package com.jiepos.mpos.biz.channel.controller 
 * @author 张学涛
 * @version 1.0
 * @since 2017年9月22日上午10:40:37
 * @history（历次修订内容、修订人、修订时间等）
 */
@Controller
@RequestMapping("infchngrp")
public class InfChnGrpController extends BaseController {
	
	@Autowired
	private InfChnGrpService infChnGrpService;
	
	
	/**
	 * 进入通道分组信息列表页面
	 * @param request
	 * @param response
	 * @param pagination
	 * @return
	 */
	@RequestMapping("/getInfChnGrpList.do")
	public ModelAndView getInfChnGrpList(HttpServletRequest request,HttpServletResponse response,Pagination pagination){
		ModelAndView model=new ModelAndView("/module/channel/infchngrp/infchngrp_list");
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 查询通道分组列表信息json数据
	 * @param pagination
	 * @param channel_grp
	 * @return
	 */
	@RequestMapping("/getInfChnGrpListJson.do")
	public @ResponseBody Map getInfChnGrpListJson(Pagination pagination,String channel_grp){
		return infChnGrpService.getInfChnGrpList(pagination, channel_grp);
	}
	
	/**
	 * 进入通道分组信息详细页面
	 * @param request
	 * @param response
	 * @param pagination
	 * @param chn_grp_uuid
	 * @return
	 */
	@RequestMapping("/getInfChnGrpDetail.do")
	public ModelAndView getInfChnGrpDetail(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination,String chn_grp_uuid){
		ModelAndView model=new ModelAndView("/module/channel/infchngrp/infchngrp_detail");
		Map infChnGrp=infChnGrpService.getInfChnGrpDetail(chn_grp_uuid);
		model.addObject("infChnGrp", infChnGrp);
		//model.addObject("chngrpname", infChnGrp.get("chngrpname"));
		//model.addObject("chnname", infChnGrp.get("chnname"));
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 保存通道分组
	 * @param request
	 * @param response
	 * @param infChnGrp
	 * @return
	 */
	@RequestMapping("/saveInfChnGrp.do")
	public ModelAndView saveInfChnGrp(HttpServletRequest request, HttpServletResponse response,App_Inf_Chn_GrpEntity infChnGrp){
		infChnGrpService.saveInfChnGrp(infChnGrp, super.getLoginUser(request, response));
		Map map=super.getLoginUser(request, response);  
		return new ModelAndView(new RedirectView("getInfChnGrpList.do"), map);
	}
	
	/**
	 * 删除通道分组
	 * @param request
	 * @param response
	 * @param chn_grp_uuids
	 * @return
	 */
	@RequestMapping("/deleteInfChnGrpByIds.do")
	public ModelAndView deleteInfChnGrpByIds(HttpServletRequest request, HttpServletResponse response,String chn_grp_uuids){
		infChnGrpService.deleteInfChnGrpByIds(chn_grp_uuids);
		Map map=super.getLoginUser(request, response);  
		return new ModelAndView(new RedirectView("getInfChnGrpList.do"), map);
	}
	
	/**
	 * 校验通道分组
	 * @param infChnGrp
	 * @return
	 */
	@RequestMapping("/checkChnGrp.do")
	public @ResponseBody String checkChnGrp(App_Inf_Chn_GrpEntity infChnGrp){		
		return infChnGrpService.checkChnGrp(infChnGrp);
	}

}
